home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / vtkerma2.arc / MSSET.ASM next >
Encoding:
Assembly Source File  |  1986-02-13  |  44.3 KB  |  1,906 lines

  1.     PAGE 59, 132
  2.  
  3.     TITLE MSSET -- Set and Status commands
  4.  
  5. ; Update 13 Jan 86
  6.  
  7. IF1
  8.  %OUT >> Starting pass 1
  9. ELSE
  10.  %OUT >> Starting pass 2
  11. ENDIF
  12.  
  13.     public setcom, status, stat0, baudprt, escprt, prmptr, dodef
  14.     public setcpt, docom, shomac, atoi, m7171, AutoWrap
  15.     include msdefs.h
  16.  
  17. setextra  equ    250
  18. macmax    equ    40        ; Maximum # of macros
  19.  
  20. datas     segment    public 'datas'
  21.  
  22.     PUBLIC MacTab, MccTab, Force_card
  23.  
  24.     extrn    comand:byte, flags:byte, trans:byte, cptfcb:byte, takadr:word
  25.     extrn    taklev:byte, inichk:byte, portval:word, curdsk:byte
  26.     EXTRN Force_mono:BYTE, In_menu_mode:BYTE, Menu_file_name:BYTE
  27.     EXTRN Reload_menu_flag:BYTE
  28.  
  29. kerm    LABEL BYTE
  30.     Program_name
  31.     db      '> $'
  32.  
  33. crlf    db      cr,lf,'$'
  34. crlfsp    db    cr,lf
  35. Blank    db    ' $'
  36. eqs    db    ' = $'
  37. ermes1    db    '? Too many macros',cr,lf,'$'
  38. ermes2    db    '? No room in table for macro',cr,lf,'$'
  39. ermes3  db      '? Not confirmed',cr,lf,'$'
  40. ermes4    db    '? No room in take stack to expand macro',cr,lf,'$'
  41. ermes5    db    '? Not implemented',cr,lf,'$'
  42. erms23    db    '? 0 or null scan code not allowed',cr,lf,'$' ;[jd] 
  43. erms24    db    '? Capture file already open (use close command)',cr,lf,'$'
  44. erms31    db    '? File not found',cr,lf,'$'
  45. erms38    db    '? Insufficient TAKE stack space to parse filename',cr,lf,'$'
  46. filmsg    db    ' File specification with optional path name$'
  47. filhlp    db    ' Input file specification for session logging$'
  48. macmsg    db    ' Macro name, followed by body of macro.',Cr,Lf
  49.     db    '   The "body of a macro" is a series of commands, separated '
  50.     db 'by commas.',Cr,Lf
  51.     db    '   Macros are executed with the "DO macro" command.$'
  52. shmmsg    db    ' Confirm with carriage return$'
  53. prmmsg    db    ' Enter new prompt string $'
  54. sk1msg    db    ' Decimal scan code for key $'
  55. sk2msg    db    ' Redefinition string for key $'
  56. prterr    db    '? Unrecognized value',cr,lf,'$'
  57. unrec    db    'BAUD rate is unknown$'
  58. defpmp    db    'Definition string: $'
  59. esctl    db    'CONTROL-$'         ; [6]
  60. nonmsg    db    'NONE$'
  61. delmsg    db    'DELETE$'
  62. onmsg    db    'ON'
  63. offmsg    db    'OFF'
  64. Disp_msg db 'DISPLAY $'
  65. Display_color db 'permitted to be COLOR'
  66. Display_mono db  'forced to be MONOCHROME'
  67. tmp    db    ?,'$'
  68. sum    db    0
  69. min    db    0
  70. max    db    0
  71. desta    dw    0
  72. numerr    dw    0
  73. numhlp    dw    0
  74. Hold_bx    DW    ?        ; Place to hold bx register
  75. Hold_di    DW    ?        ; Place to hold di register
  76. Hold_ax    DW    ?        ; Place to hold ax register
  77. stflg    db    0        ; Says if setting SEND or RECEIVE parameter.
  78. srtmp    db    0
  79. Force_card db    0FFh        ; Flag that we are not forcing the card
  80. savsp    dw    0
  81. temp    dw    0
  82. temp1   dw      ?               ; Temporary storage.
  83. temp2   dw      ?               ; Temporary storage.
  84.  
  85. b03st    db    'BAUD rate is 300$'
  86. b12st    db    'BAUD rate is 1200$'
  87. b18st    db    'BAUD rate is 1800$'
  88. b24st    db    'BAUD rate is 2400$'
  89. b48st    db    'BAUD rate is 4800$'
  90. b96st    db    'BAUD rate is 9600$'
  91. b04st    db    'BAUD rate is 45.5$'
  92. b05st    db    'BAUD rate is 50$'
  93. b07st    db    'BAUD rate is 75$'
  94. b11st    db    'BAUD rate is 110$'
  95. b13st    db    'BAUD rate is 134.5$'
  96. b15st    db    'BAUD rate is 150$'
  97. b06st    db    'BAUD rate is 600$'
  98. b20st    db    'BAUD rate is 2000$'
  99. b19st    db    'BAUD rate is 19200$'
  100. b23st    db    'BAUD rate is 23040$'
  101. b38st    db    'BAUD rate is 38400$'
  102.  
  103. parmsg    db    'PARITY is $'
  104. locst   db      'LOCAL-ECHO is $'
  105. belon    db    'Ring BELL after transfer$'
  106. beloff    db    'No BELL after transfer$'
  107. Take_echo_is DB 'TAKE-ECHO is $'
  108. cm1st    db    'Communications PORT: 1$'
  109. cm2st    db    'Communications PORT: 2$'
  110. capmsg    db    'LOG is $'
  111. eofmsg    db    'EOF mode is $'
  112. flost    db    'No FLOW-CONTROL used$'
  113. floxmsg    db    'FLOW-CONTROL is XON/XOFF $'
  114. handst    db    'HANDSHAKE is $'
  115. destst    db    'File DESTINATION is $'
  116. diskst    db    'DEFAULT-DISK is $'
  117. blokst    db    'BLOCK-CHECK is $'
  118. Mode_is    db    'MODE is $'
  119. ebyst    db    '8-bit quoting done only on request$'
  120. ebvst    db    '8-bit quoting will be done with: $'
  121. escmes  db      'ESCAPE character is $'
  122. ;debon    db    'DEBUG mode is $'
  123. flwon    db    'WARNING is $'
  124. timmsg    db    'TIMER is $'
  125. abfdst    db    'INCOMPLETE file: DISCARD$'
  126. abfkst    db    'INCOMPLETE file: KEEP$'
  127. eolst    db    'END-OF-LINE character is $'
  128. m7171st    db    '7171-MODE is $'
  129. AutoWrSt db    'AUTOWRAP-MODE is $'
  130.  
  131. sqcst    db    'SEND cntrl char prefix:    $'
  132. rqcst    db    'RECEIVE cntrl char prefix:    $'
  133. ssohst    db    'SEND start-of-packet char: $'
  134. rsohst    db    'RECEIVE start-of-packet char: $'
  135. stimst    db    'SEND TIMEOUT (seconds):    $'
  136. rtimst    db    'RECEIVE TIMEOUT (seconds):    $'
  137. spakst    db    'SEND PACKET-LENGTH:        $'
  138. rpakst    db    'RECEIVE PACKET-LENGTH:        $'
  139. snpdst    db    'SEND # of PAD chars:       $'
  140. rnpdst    db    'RECEIVE # of PAD chars:       $'
  141.  
  142. eolhlp    db    cr,lf,'Decimal number between 0 and 31$'
  143. eolerr    db    cr,lf,'Illegal end-of-line character$'
  144. timerr    db    cr,lf,'Illegal timeout value$' 
  145. timhlp    db    cr,lf,'Decimal number between 0 and 94$'
  146. soherr    db    cr,lf,'Illegal start-of-packet character$'
  147. quohlp    db    cr,lf,'Decimal number between 33 and 126$'
  148. quoerr    db    cr,lf,'Illegal control character prefix$'
  149. pakerr    db    cr,lf,'Illegal packet length$'
  150. pakhlp    db    cr,lf,'Decimal number between 20 and 94$'
  151. npderr    db    cr,lf,'Illegal number of pad characters$'
  152. npdhlp    db    cr,lf,'Decimal number between 0 and 99$'
  153. paderr    db    cr,lf,'Illegal pad character$'
  154. padhlp    db    cr,lf,'Decimal number between 0 and 31 or 127$'
  155. eschlp  db      cr,lf,'Enter literal value (ex: Cntrl ])  $'
  156. desterr    db    cr,lf,'Illegal destination device$'
  157. dskhlp    db    cr,lf,'Default disk drive to use, such as A:$'
  158. dskerr    db    cr,lf,'Invalid drive specification$' 
  159.  
  160. sethlp    db      cr,lf,' AUTOWRAP-MODE on/off',tab,tab,'BAUD rate'
  161.     db    cr,lf,' BELL on/off',tab,tab,tab,'BLOCK-CHECK-TYPE'
  162.     db    cr,lf,' DEBUG on/off',tab,tab,tab,'DEFAULT-DISK'
  163.     db    cr,lf,' DESTINATION file/printer',tab,'DISPLAY color/mono'
  164.     db    cr,lf,' END-OF-LINE character',tab,tab,'EOF ctrl-z/noctrl-z'
  165.     db    cr,lf,' ESCAPE character',tab,tab,'FLOW-CONTROL'
  166.     db    cr,lf,' HANDSHAKE',tab,tab,tab,'INCOMPLETE file'
  167.     db    cr,lf,' KEY scan code',tab,tab,tab,'LOCAL-ECHO on/off'
  168.     db    cr,lf,' MENU-FILE filename',tab,tab,'MODE command/menu'
  169.     db    cr,lf,' PARITY type',tab,tab,tab,'PORT com1/com2'
  170.     db    cr,lf,' PROMPT string',tab,tab,tab,'RECEIVE parameter'
  171.     db    cr,lf,' REMOTE on/off',tab,tab,tab,'SEND parameter'
  172.     db    cr,lf,' TAKE-ECHO on/off',tab,tab,'TIMER on/off'
  173.     db    cr,lf,' WARNING on/off',tab,tab,tab,'7171-MODE on/off'
  174.     db    '$'
  175.  
  176. settab  db      29
  177.     mkeyw    '7171-MODE', m71onoff
  178.     mkeyw    'AUTOWRAP-MODE', AutWrpOnOff
  179.     mkeyw    'BAUD',baudst
  180.     mkeyw    'BELL',bellst
  181.     mkeyw    'BLOCK-CHECK-TYPE',blkset
  182.     mkeyw    'CARD',Set_card
  183.     mkeyw    'DEBUG',debst
  184.     mkeyw    'DEFAULT-DISK',dskset
  185.     mkeyw    'DESTINATION',desset
  186.     mkeyw    'DISPLAY',Set_display
  187.     mkeyw    'END-OF-LINE',eolset
  188.     mkeyw    'EOF',seteof
  189.     mkeyw    'ESCAPE',escape
  190.     mkeyw    'FLOW-CONTROL',floset
  191.     mkeyw    'HANDSHAKE',hndset
  192.     mkeyw    'INCOMPLETE',abfset
  193.     mkeyw    'KEY',setkey
  194.     mkeyw    'LOCAL-ECHO',lcal
  195.     mkeyw    'MENU-FILE', Set_menu_file
  196.     mkeyw    'MODE', Set_mode
  197.     mkeyw    'PARITY',setpar
  198.     mkeyw    'PORT',comset
  199.     mkeyw    'PROMPT',promset
  200.     mkeyw    'RECEIVE',recset
  201.     mkeyw    'REMOTE',remset
  202.     mkeyw    'SEND',sendset
  203.     mkeyw    'TAKE-ECHO',takset
  204.     mkeyw    'TIMER',timset
  205.     mkeyw    'WARNING',filwar
  206.  
  207.  
  208. seoftab    db    2
  209.     mkeyw    'CTRL-Z',1
  210.     mkeyw    'NOCTRL-Z',0
  211.  
  212. stsrtb    db    06        ; Number of options.
  213.     mkeyw    'PACKET-LENGTH',srpack
  214.     mkeyw    'PADCHAR',srpad
  215.     mkeyw    'PADDING',srnpd
  216.     mkeyw    'QUOTE',srquo
  217.     mkeyw    'START-OF-PACKET',srsoh
  218.     mkeyw    'TIMEOUT',srtim
  219.  
  220. ontab   db      02H             ; Two entries.
  221.     mkeyw    'OFF',00H
  222.     mkeyw    'ON',01H
  223.  
  224. destab    db    02H        ; Two choices.
  225.     mkeyw    'DISK',01H
  226.     mkeyw    'PRINTER',00H
  227.  
  228. ; What type of block check to use.
  229. blktab    db    03H
  230.     mkeyw    '1-CHARACTER-CHECKSUM',1
  231.     mkeyw    '2-CHARACTER-CHECKSUM',2
  232.     mkeyw    '3-CHARACTER-CRC-CCITT',3
  233.  
  234. ; If abort when receiving files, can keep what we have or discard. [20d]
  235.  
  236. abftab    db    02H        ; Only two options. 
  237.     mkeyw    'DISCARD',01H
  238.     mkeyw    'KEEP',00H
  239.  
  240. Mode_table DB 2
  241.     mkeyw    'COMMAND', 0
  242.     mkeyw    'MENU', 0FFh
  243.  
  244. partab    db    05H        ; Five entries.            [10 start]
  245.     mkeyw    'EVEN',PAREVN
  246.     mkeyw    'MARK',PARMRK
  247.     mkeyw    'NONE',PARNON
  248.     mkeyw    'ODD',PARODD
  249.     mkeyw    'SPACE',PARSPC
  250.  
  251. flotab    db    2
  252.     mkeyw    'NONE',flonon
  253.     mkeyw    'XON/XOFF',floxon
  254.  
  255. hndtab    db    7
  256.     mkeyw    'BELL',bell
  257.     mkeyw    'CR',cr
  258.     mkeyw    'ESC',esc
  259.     mkeyw    'LF',lf
  260.     mkeyw    'NONE',0
  261.     mkeyw    'XOFF',xoff
  262.     mkeyw    'XON',xon
  263.  
  264. BStab    db    02H            ;Two entries [19c start]
  265.     mkeyw    'BACKSPACE',00H
  266.     mkeyw    'DELETE',01H
  267.  
  268. bdtab    db    17
  269.     mkeyw    '110',b0110
  270.     mkeyw    '1200',b1200
  271.     mkeyw    '134.5',b01345
  272.     mkeyw    '150',b0150
  273.     mkeyw    '1800',b1800
  274.     mkeyw    '19200',b19200
  275.     mkeyw    '2000',b2000
  276.     mkeyw    '23040',b23040
  277.     mkeyw    '2400',b2400
  278.     mkeyw    '300',b0300
  279.     mkeyw    '38400',b38400
  280.     mkeyw    '45.5',b00455
  281.     mkeyw    '4800',b4800
  282.     mkeyw    '50',b0050
  283.     mkeyw    '600',b0600
  284.     mkeyw    '75',b0075
  285.     mkeyw    '9600',b9600
  286.  
  287. Display_tab db 2
  288.     mkeyw 'COLOR', 0
  289.     mkeyw 'MONOCHROME', 1
  290.  
  291. Card_tab db 4
  292.     mkeyw 'COLOR', 1
  293.     mkeyw 'DEFAULT', 0FFh
  294.     mkeyw 'EGA', 2
  295.     mkeyw 'MONOCHROME', 0
  296.  
  297.  
  298. ten    dw    10            ; multiplier for setatoi
  299. rdbuf    db    80H DUP(?)
  300. prm    db    30 dup(0)        ; Buffer for new prompt.
  301. prmptr    dw    kerm            ; pointer to prompt
  302. m7171    db    0            ; in 7171 mode
  303. AutoWrap db    0            ; In AutoWrap mode
  304. defkw    db    100 dup (?)
  305. macnum    dw    0            ; one macro yet
  306. mactab    dw    Exitmac            ; default Exit mac is macro 0
  307.     dw    macmax dup (?)        ; empty macro table
  308. defptr    dw    macbuf
  309. macbuf    db    macmax*100 dup (?)    ; buffer for macro defs
  310. rmlft    db    setextra        ; space left in set table
  311. mcctab    db    1            ; macro cmd table, one initially
  312.     mkeyw    'EXIT',0        ; macro # 0
  313.     db    setextra dup (?)    ; room for more.
  314.  
  315. Exitmac    DB    imlen-1
  316.     DB    'Drop-Dtr',Cr,'Exit',Cr
  317. imlen    equ    $-Exitmac
  318.  
  319. ; structure for status information
  320. stent    struc
  321. sttyp    dw    ?        ; type (actually routine to call)
  322. msg    dw    ?        ; message to print
  323. val2    dw    ?        ; needed value: another message, or tbl addr
  324. tstcel    dw    ?        ; address of cell to test, in data segment
  325. basval    dw    0        ; base value, if non-zero
  326. stent    ends
  327.  
  328. ;    stent    <onoff,vtemst,,flags.vtflg>
  329.  
  330. sttab    stent    <baudprt>
  331.     stent    <srchkw,parmsg,partab,parflg,portval>
  332.     stent    <msg2,cm2st,cm1st,flags.comflg>
  333.     stent    <onechr,escmes,,trans.escchr>
  334.     stent    <onoff,locst,,ecoflg,portval>
  335.     stent    <onoff,capmsg,,flags.capflg>
  336.     stent    <msg2,flost,floxmsg,floflg,portval>
  337.     stent    <prhnd>
  338.     stent    <srchkw,destst,destab,flags.destflg>
  339.     stent    <drnum,diskst,,curdsk>
  340.     stent    <onoff,flwon,,flags.flwflg>
  341.     stent    <msg2,beloff,belon,flags.belflg>
  342.     stent    <srchkw,eofmsg,seoftab,flags.eofcz>
  343.     stent    <msg2,abfkst,abfdst,flags.abfflg>
  344.     stent    <onoff,timmsg,,flags.timflg>
  345.     stent    <onoff,Take_echo_is,,flags.takflg>
  346.     stent    <pr8bit>
  347.     stent    <onechr,eolst,,trans.seol>
  348.     stent    <onoff,m7171st,,m7171>
  349.     stent    <Display,Disp_msg,,Force_mono>
  350.     stent    <srchkw,blokst,blktab,trans.chklen>
  351.     stent    <onoff,AutoWrSt,,AutoWrap>
  352.  
  353. ; File transfer params
  354.     stent    <onechr,sqcst,,trans.rquote>
  355.     stent    <onechr,rqcst,,trans.squote>
  356.     stent    <onechr,ssohst,,trans.ssoh>
  357.     stent    <onechr,rsohst,,trans.rsoh>
  358.     stent    <stnum,stimst,,trans.stime>
  359.     stent    <stnum,rtimst,,trans.rtime>
  360.     stent    <stnum,spakst,,trans.spsiz>
  361.     stent    <stnum,rpakst,,trans.rpsiz>
  362.     stent    <stnum,snpdst,,trans.spad>
  363.     stent    <stnum,rnpdst,,trans.rpad>
  364.  
  365.     stent    <SrchKw,Mode_is,Mode_table,In_menu_mode>
  366.  
  367. ;    stent    <onoff,debon,,flags.debug>
  368.     dw    0        ; end of table
  369. sttbuf    db    2000 dup (?)    ; big buffer for status msg.
  370. datas    ends
  371.  
  372. code    segment    public
  373.     extrn cmcfrm:near, prserr:near, comnd:near, dobaud:near
  374.     extrn cmgtch:near, repars:near, coms:near, defkey:near
  375.     extrn inicpt:near, prompt:near, nout:near, prtscr:near
  376.     extrn prkey:near, serrst:NEAR, serini:NEAR, SPath:NEAR
  377.     EXTRN Parse_for_Set_Key:NEAR, Get_Set_Key_table_size:NEAR
  378.     assume    cs:code,ds:datas
  379.  
  380. ; This is the SET command.
  381.  
  382. SETCOM  PROC    NEAR
  383.     mov dx,offset settab    ; Parse a keyword from the set table.
  384.     mov bx,offset sethlp
  385.     mov ah,cmkey
  386.     call comnd
  387.      jmp r
  388.     jmp bx            ; Run the routine
  389. SETCOM    endp
  390.  
  391. docom    proc    near
  392.     mov    dx,offset mcctab
  393.     mov    bx,0
  394.     mov    ah,cmkey
  395.     call    comnd
  396.      jmp    r
  397.     push    bx
  398.     mov    ah,cmcfm
  399.     call    comnd
  400.      pop    bx
  401.      ret
  402.      nop
  403.     pop    bx
  404.     cmp    taklev,maxtak        ; room in take level?
  405.     jl    docom2            ; yes, continue
  406.     mov    dx,offset ermes4    ; else complain
  407.     jmp    reterr
  408. docom2:    inc    taklev            ; increment take level (overflow)
  409.     add    takadr,size takinfo
  410.     shl    bx,1
  411.     mov    si,mactab[bx]        ; point to macro
  412.     mov    cl,[si]            ; get size from macro
  413.     mov    ch,0
  414.     inc    si            ; point to actual definition
  415.     mov    bx,takadr        ; point to current buffer
  416.     mov    [bx].takfcb,0ffh    ; flag as a macro
  417.     mov    [bx].takptr,si        ; point to beginning of def
  418.     mov    [bx].takchl,cl        ; # of chars left in buffer
  419.     mov    [bx].takcnt,cx        ; and in definition
  420.     mov    word ptr [bx].takcnt+2,0 ; zero high order...
  421.     jmp    rskp
  422. docom    endp
  423.  
  424. ; the define command
  425. dodef    proc    near
  426.     cmp    macnum,macmax        ; get current macro count
  427.     jl    dode1            ; no, go on
  428.     mov    dx,offset ermes1    ; else complain
  429.     jmp    reterr            ; and return
  430.  
  431. dode1:    mov    ah,cmtxt
  432.     mov    bx,offset defkw+1    ; buffer for keyword
  433.     mov    dx,offset macmsg
  434.     call    comnd
  435.      ret
  436.      nop
  437.      nop
  438.     cmp    ah,0
  439.     jne    dode2
  440.     jmp RSkp
  441. dode2:    push    es
  442.     mov    bx,ds
  443.     mov    es,bx
  444.     cld
  445.     mov    cl,ah
  446.     mov    ch,0            ; length
  447.     mov    si,offset defkw+1    ; pointer to keyword
  448.     mov    ah,0            ; # of chars in keyword
  449. ; uppercase keyword, look for end
  450. dode3:    lodsb                ; get a byte
  451.     cmp    al,'a'
  452.     jb    dode4
  453.     cmp    al,'z'
  454.     ja    dode4
  455.     sub    al,'a'-'A'
  456.     mov    [si-1],al        ; uppercase if necessary
  457. dode4:    inc    ah            ; increment word count
  458.     cmp    al,' '            ; is it the break character?
  459.     loopne    dode3            ; no, loop thru rest of word
  460. dode5:    jne    dode6            ; ended with break char?
  461.     dec    ah            ; yes, don't count in length
  462. dode6:    mov    defkw,ah        ; store length in front of it
  463.     add    ah,4            ; add keyword overhead length
  464.     cmp    ah,rmlft        ; will it fit in buffer
  465.     jb    dode7            ; yes, keep going
  466.     mov    dx,offset ermes2    ; else complain
  467.     jmp    reterr
  468.  
  469. dode7:    sub    rmlft,ah        ; subtract space used in tbl
  470.     mov    di,defptr        ; pointer to free space
  471.     inc    macnum            ; count the macro
  472.     mov    bx,macnum
  473.     shl    bx,1            ; double for word idx!!!
  474.     mov    mactab[bx],di        ; install into table
  475.     mov    [di],cl            ; store length
  476.     inc    di
  477.     jcxz    dode10            ; no copy if 0 length
  478.  
  479. ; copy definition into buffer, changing commas to crs
  480. dode8:    lodsb                ; get a byte
  481.     cmp    al,','            ; comma?
  482.     jne    dode9            ; no, keep going
  483.     mov    al,cr            ; else replace with cr
  484. dode9:    stosb
  485.     loop    dode8            ; keep copying
  486.  
  487. dode10:    mov    defptr,di        ; update free ptr
  488.     mov    bl,defkw
  489.     mov    bh,0
  490.     lea    di,defkw+1[bx]        ; end of keyword
  491.     mov    al,'$'
  492.     stosb
  493.     mov    ax,macnum
  494.     stosb                ; low-order
  495.     mov    al,0            ; high-order is always 0.
  496.     stosb
  497.  
  498. ; now install into table
  499.     pop    es
  500.     mov    bx,offset mcctab
  501.     mov    dx,offset defkw
  502.     call    addtab
  503.     jmp    rskp
  504. dodef    endp
  505.  
  506. ; add an entry to a keyword table
  507. ; enter with bx/ table address, dx/ ptr to new entry
  508. ; no check is made to see if the entry fits in the table.
  509. addtab    PROC    NEAR
  510.     push    es
  511.     cld
  512.     mov    ax,ds
  513.     mov    es,ax        ; address data segment
  514.     mov    bp,bx        ; remember where tbl starts
  515.     mov    cl,[bx]        ; pick up length of table
  516.     mov    ch,0
  517.     inc    bx        ; point to actual table...
  518. addta1:    push    cx        ; preserve count
  519.     mov    si,dx        ; point to entry
  520.     lodsb            ; get length of new entry
  521.     mov    cl,[bx]        ; and length of table entry...
  522.     mov    ah,0        ; assume they're the same size
  523.     cmp    al,cl        ; are they the same?
  524.     lahf            ; remember result of comparison...
  525.     jae    addta2        ; is new smaller? no, use table length
  526.     mov    cl,al        ; else use length of new entry
  527. addta2:    mov    ch,0
  528.     lea    di,[bx+1]    ; point to actual keyword
  529.     repe    cmpsb        ; compare strings
  530.     pop    cx        ; restore count
  531.     jb    addta4        ; below, insert before this one
  532.     jne    addta3        ; not below or same, keep going
  533.     sahf            ; same. get back result of length comparison
  534.     jb    addta4        ; if new len is smaller, insert here
  535.     jne    addta3        ; if not same size, keep going
  536.     mov    si,bx        ; else this is where entry goes
  537.     jmp    short addta6    ; no insertion required...
  538. addta3:    mov    al,[bx]
  539.     mov    ah,0
  540.     add    bx,ax        ; skip this entry
  541.     add    bx,4        ; len + $ + value...
  542.     loop    addta1        ; and keep looking
  543. addta4:    mov    si,bx        ; this is first location to move
  544.     mov    di,bx
  545.     inc    ds:byte ptr [bp] ; remember we're adding one...
  546.     jcxz    addta6        ; no more entries, forget this stuff
  547.     mov    bh,0        ; this stays 0
  548. addta5:    mov    bl,[di]        ; get length
  549.     lea    di,[bx+di+4]    ; end is origin + length + 4 for len, $, value
  550.     loop    addta5        ; loop thru remaining keywords
  551.     mov    cx,di
  552.     sub    cx,si        ; compute # of bytes to move
  553.     push    si        ; preserve loc for new entry
  554.     mov    si,di        ; first to move is last
  555.     dec    si        ; minus one
  556.     mov    di,dx        ; new entry
  557.     mov    bl,[di]        ; get length
  558.     lea    di,[bx+si+4]    ; dest is source + length of new + 4
  559.     std            ; move backwards
  560.     rep    movsb        ; move the table down
  561.     cld            ; put flag back
  562.     pop    si
  563. addta6:    mov    di,si        ; this is where new entry goes
  564.     mov    si,dx        ; this is where it comes from
  565.     mov    cl,[si]        ; length
  566.     mov    ch,0
  567.     add    cx,4        ; overhead bytes
  568.     rep    movsb        ; stick it in
  569.     pop    es
  570.     ret            ; and return
  571. addtab    endp
  572.  
  573. ; Show defined macros.
  574. SHOMAC    PROC    NEAR
  575.     mov ah,cmtxt
  576.     mov bx,offset rdbuf
  577.     mov dx,offset shmmsg
  578.     call comnd
  579.      jmp r 
  580.     cmp ah,0        ; Bare CR means show all macros.
  581.     jne shom2        ; No, he wants specific macro expanded.
  582.     mov si,offset mcctab    ; Table of macro names.
  583.     lodsb
  584.     mov cl,al        ; Number of macro entries.
  585.     mov ch,0
  586.     jcxz shom1        ; Done if none left to display.
  587.  
  588. shom0:    lodsb            ; Length of macro name.
  589.     push ax            ; Don't forget it.
  590.  
  591.     mov ah,prstr
  592.     mov dx, OFFSET Blank    ; Indent by one space
  593.     int dos
  594.  
  595.     mov dx,si        ; Print macro name.
  596.     int dos
  597.     mov dx,offset eqs
  598.     int dos
  599.     pop ax
  600.     mov ah,0
  601.     add si,ax        ; Skip over name.
  602.     inc si            ; Get to macro number.
  603.     mov bx,[si]        ; Pick it up.
  604.     call expmac        ; Expand the macro.
  605.     add si,2        ; Skip over macro number.
  606.  
  607.     mov ah, PrStr
  608.     mov dx, OFFSET CrLf
  609.     int Dos
  610.  
  611.     loop shom0        ; Do more if any
  612.  
  613. shom1:    jmp rskp
  614.  
  615. shom2:    mov ah,prstr
  616.     mov dx,offset ermes3
  617.     int Dos
  618.  
  619.     jmp rskp
  620.  
  621. SHOMAC    ENDP
  622.  
  623. ; Expand the macro, called with BX/macro number.
  624. expmac:    push si
  625.     push cx
  626.     mov si,offset mactab    ; Table of address expansions.
  627.     shl bx,1        ; Double and use as index into table.
  628.     mov si,[si+bx]        ; Get address of expansion in question.
  629.     mov ax,si        ; Address of string.
  630.     inc ax            ; Don't print length.
  631.     mov cl,[si]        ; Length of string.
  632.     mov ch,0
  633.     call prkey        ; Print it.
  634.     pop cx
  635.     pop si
  636.     ret
  637.  
  638. seteof    proc    near
  639.     mov ah,cmkey
  640.     mov bx,0
  641.     mov dx,offset seoftab
  642.     call comnd
  643.      jmp r
  644.     push bx
  645.     mov ah,cmcfm
  646.     call comnd
  647.      jmp seteo1        ; error return...
  648.      nop
  649.     pop bx
  650.     mov flags.eofcz,bl    ; set value
  651.     jmp rskp        ; and return
  652. seteo1:    pop bx
  653.     ret
  654. seteof    endp
  655.  
  656. ;       This is the ESCAPE character SET subcommand.     [6 start]
  657.  
  658. ESCAPE  PROC    NEAR
  659.     call cmgtch        ; Get a char.
  660.     cmp ah,0
  661.     jns es1            ; Terminator or no?
  662.     and ah,7FH        ; Turn off minus bit.
  663.     cmp ah,'?'
  664.     jne es0
  665.     mov dx,offset eschlp
  666.     mov ah,prstr
  667.     int dos
  668.     mov dx,offset crlf
  669.     int dos
  670.     mov dx,comand.cmprmp
  671.     int dos
  672.     mov bx,comand.cmdptr
  673.     mov al,'$'
  674.     mov [bx],al
  675.     mov dx,offset comand.cmdbuf
  676.     int dos
  677.     dec comand.cmcptr        ; Ignore dollar sign.
  678.     dec comand.cmccnt
  679.     mov comand.cmaflg,0
  680.     jmp repars
  681. es0:    mov ah,prstr
  682.     mov dx,offset ermes3
  683.     int dos
  684.     jmp RSkp
  685. es1:      mov temp,ax
  686.     call cmcfrm
  687.      jmp es0
  688.      nop            ; Take up 3 bytes.
  689.     mov ax,temp
  690.     mov trans.escchr,ah    ; Save new value.
  691.     jmp RSkp
  692. ESCAPE  ENDP            ; [6 end]
  693.  
  694. ;     This is the End-of-line character SET subcommand.
  695.  
  696. EOLSET    PROC    NEAR
  697.     mov min,0
  698.     mov max,1FH
  699.     mov sum,0
  700.     mov tmp,10
  701.     mov temp1,0
  702.     mov desta,offset trans.seol
  703.     mov numhlp,offset eolhlp
  704.     mov numerr,offset eolerr
  705.     jmp num0        ; Common routine for parsing numerical input.
  706. EOLSET    ENDP
  707.  
  708. num0:    call cmgtch        ; Get the first char into AH.
  709.     cmp ah,0
  710.     js num1
  711.     cmp ah,'0'
  712.     jl num1
  713.     cmp ah,'9'
  714.     ja num1
  715.     mov temp1,1
  716.     sub ah,30H
  717.     mov dl,ah
  718.     mov al,sum
  719.     mul tmp
  720.     add al,dl
  721.     mov sum,al
  722.     jmp num0
  723. num1:    and ah,7FH
  724.     cmp ah,CR
  725.     jne num2
  726.     cmp temp1,0
  727.     je num21
  728.     mov al,sum
  729.     cmp al,min
  730.     jl num3
  731.     cmp al,max
  732.     jg num3
  733.     mov bx,desta
  734.     mov [bx],al
  735.     ret
  736. num2:    cmp ah,03FH        ; Question mark?
  737.     je num4
  738. num21:    mov ah,prstr
  739.     mov dx,offset ermes3
  740.     int dos
  741.     jmp prserr
  742. num3:    mov ah,prstr
  743.     mov dx,numerr
  744.     int dos
  745.     jmp prserr
  746. num4:    mov ah,prstr
  747.     mov dx,numhlp
  748.     int dos
  749.     mov dx,offset crlf
  750.     int dos
  751.     mov dx,comand.cmprmp
  752.     int dos
  753.     mov bx,comand.cmdptr
  754.     mov al,'$'
  755.     mov [bx],al
  756.     mov dx,offset comand.cmdbuf
  757.     int dos
  758.     dec comand.cmcptr        ; Don't count the dollar sign.
  759.     dec comand.cmccnt        ; Or the question mark.
  760.     mov comand.cmaflg,0        ; Check for more input.
  761.     jmp repars
  762.  
  763. ;       This is the LOCAL echo SET subcommand.
  764.  
  765. LCAL    PROC    NEAR
  766.     mov dx,offset ontab
  767.     mov bx,0
  768.     mov ah,cmkey
  769.     call comnd
  770.      jmp r
  771.     push bx                 ; Save the parsed value.
  772.     mov ah,cmcfm
  773.     call comnd              ; Get a confirm.
  774.      jmp lcl0        ;  Didn't get a confirm.
  775.      nop
  776.     pop bx
  777.     mov si,portval
  778.     mov [si].ecoflg,bl     ; Set the local echo flag.
  779. ;tm    mov [si].hndflg,bl    ; This goes on/off with local echo.
  780.     xor bl,01        ; Toggle this.
  781. ;tm    mov [si].floflg,bl    ; This is the opposite.
  782.     jmp RSkp
  783. lcl0:    pop bx
  784.     ret
  785. LCAL    ENDP
  786.  
  787. ; This is the SET subcommand to choose between COM1 and COM2. [19b]
  788.   
  789. COMSET  PROC    NEAR
  790.     call serrst        ; Reset the old port, if any, uninstalling
  791.                 ;  interrupt handler
  792.     call coms        ; Switch to the desired port (may be same)
  793.     call serini        ; Then turn on the port and install interrupt
  794.                 ;  handler
  795.     jmp RSkp        ; Return to command loop
  796. COMSET  ENDP
  797.  
  798. FILWAR  PROC    NEAR
  799.     mov dx,offset ontab
  800.     mov bx,0
  801.     mov ah,cmkey
  802.     call comnd
  803.      jmp r
  804.     push bx
  805.     mov ah,cmcfm
  806.     call comnd              ; Get a confirm.
  807.      jmp fil0        ; Didn't get a confirm.
  808.      nop
  809.     pop bx
  810.     mov flags.flwflg,bl     ; Set the filewarning flag.
  811.     jmp RSkp
  812. fil0:    pop bx
  813.     ret
  814. FILWAR  ENDP
  815.  
  816.  
  817. ; Turn on or off the setting of 7171 mode
  818.  
  819. m71onoff PROC
  820.  
  821.     mov dx,offset ontab
  822.     mov bx,0
  823.     mov ah,cmkey
  824.     call comnd
  825.      jmp r
  826.     push bx
  827.     mov ah,cmcfm
  828.     call comnd              ; Get a confirm
  829.      jmp m7x        ;  Didn't get a confirm
  830.      nop
  831.     pop bx
  832.     mov m7171,bl        ; Store the new setting
  833.     jmp RSkp
  834. m7x:    pop bx
  835.     ret
  836.  
  837. m71onoff ENDP
  838.  
  839. ; Turn on or off the setting of AutoWrap mode
  840.  
  841. AutWrpOnOff PROC
  842.  
  843.     mov dx,offset ontab
  844.     mov bx,0
  845.     mov ah,cmkey
  846.     call comnd
  847.      jmp r
  848.     push bx
  849.     mov ah,cmcfm
  850.     call comnd              ; Get a confirm
  851.      jmp AuWrx        ;  Didn't get a confirm
  852.      nop
  853.     pop bx
  854.     mov AutoWrap, bl    ; Store the new setting
  855.     jmp RSkp
  856. AuWrx:    pop bx
  857.     ret
  858.  
  859. AutWrpOnOff ENDP
  860.  
  861. ;       This is the SET aborted-file command.  [20d]
  862.  
  863. ABFSET  PROC    NEAR
  864.     mov dx,offset abftab
  865.     mov bx,0
  866.     mov ah,cmkey
  867.     call comnd
  868.      jmp r
  869.     push bx
  870.     mov ah,cmcfm
  871.     call comnd              ; Get a confirm.
  872.      jmp abf0        ;  Didn't get a confirm.
  873.      nop
  874.     pop bx
  875.     mov flags.abfflg,bl     ; Set the aborted file flag.
  876.     jmp RSkp
  877. abf0:    pop bx
  878.     ret
  879. ABFSET  ENDP
  880.  
  881.  %OUT >> About half way through source file
  882.  
  883. ;       This is the SET Parity command.                [10 start]
  884.  
  885. SETPAR  PROC    NEAR
  886.     mov dx,offset partab
  887.     mov bx,0
  888.     mov ah,cmkey
  889.     call comnd
  890.      jmp r
  891.  
  892.     mov Hold_bx, bx
  893.     mov ah,cmcfm
  894.     call comnd              ; Get a confirm.
  895.      jmp R
  896.  
  897.     mov bx, Hold_bx
  898.  
  899.     mov si,portval
  900.     mov [si].parflg,bl    ; Set the parity flag.
  901.     cmp bl,parnon        ; Resetting parity to none? [21b]
  902.     je setp0        ; Yes, reset 8 bit quote character. [21b]
  903.     mov trans.ebquot,dqbin    ; Else, do quoting.  [21b]
  904.     jmp RSkp            ; That's it.  [21b]
  905. setp0:    mov trans.ebquot,'Y'    ; If none, say will quote upon request. [21b]
  906.     jmp RSkp
  907. par0:    pop bx
  908.     ret
  909. SETPAR  ENDP                            ; [10 end]
  910.  
  911.  
  912. ; SET MENU-FILE command -- sets name of next MENU file
  913.  
  914. Set_Menu_file PROC
  915.  
  916.     cld            ; Forwards
  917.     cmp TakLev, MaxTak    ; Hit our limit?
  918.      jl SMF_1        ;  Continue if still OK
  919.  
  920.     mov ah, PrStr
  921.     mov dx, OFFSET ErMs38    ; Complain
  922.     int Dos
  923.  
  924.     jmp RSkp
  925.  
  926. SMF_1:    mov di, TakAdr
  927.     add di, SIZE TakInfo
  928.     mov Hold_di, di        ; Save reg
  929.  
  930.     mov ah, CmTxt
  931.     lea bx, [di].TakBuf    ; Convenient place to parse name into
  932.     mov dx, OFFSET FilMsg    ; Help in case user types "?"
  933.     call comnd        ; Parse for a text string
  934.      jmp RSkp        ;  Can't get text string (?), give up
  935.  
  936.     mov di, Hold_di        ; Restore reg
  937.     lea si, [di].TakBuf    ; Get buffer back
  938.     mov bl, ah        ; Length of thing parsed
  939.     sub bh, bh        ; Zero top half
  940.     mov BYTE PTR [bx+si], 0    ; Make it ASCIZ
  941.     mov Hold_ax, ax        ; Save ax for a moment
  942.     mov ax, si        ; Point to name again
  943.     call SPath        ; Is it around?
  944.      jc SMF_2        ;  No, go complain
  945.  
  946.     mov di, Hold_di        ; Restore reg
  947.     lea si, [di].TakBuf    ; Get buffer back
  948.     mov di, OFFSET Menu_file_name ; Ptr to where menu file name is stored
  949.     mov cl, BYTE PTR Hold_ax + 1 ; Pick up count
  950.     sub ch, ch        ; Clear high half
  951.     rep movsb        ; Copy menu file name
  952.  
  953.     mov Reload_menu_flag, 1    ; Flag that we need to reload the menu file
  954.     jmp RSkp        ; Done here
  955.     
  956.  
  957. SMF_2:    mov ah,prstr
  958.     mov dx,offset erms31
  959.     int dos
  960.     jmp RSkp
  961.  
  962. Set_Menu_file ENDP
  963.  
  964.  
  965. ; SET MODE command -- sets COMMAND or MENU mode
  966.  
  967. Set_Mode PROC
  968.  
  969.     mov dx, OFFSET Mode_table
  970.     mov bx, 0
  971.     mov ah, cmkey
  972.     call comnd
  973.      jmp RSkp
  974.  
  975.     mov Hold_bx, bx
  976.     mov ah, CmCfm
  977.     call Comnd              ; Get a confirm
  978.      jmp R            ;  Didn't get a confirm
  979.  
  980.     mov bx, Hold_bx
  981.     mov In_menu_mode, bl    ; Store the flag
  982.  
  983.     jmp RSkp
  984.  
  985. Set_Mode ENDP
  986.  
  987.  
  988. ; Sets debugging mode on and off.
  989.  
  990. DEBST    PROC    NEAR
  991.     mov dx,offset ontab
  992.     mov bx,0
  993.     mov ah,cmkey
  994.     call comnd
  995.      jmp r
  996.     push bx
  997.     mov ah,cmcfm
  998.     call comnd              ; Get a confirm.
  999.      jmp deb0        ; Didn't get a confirm.
  1000.      nop
  1001.     pop bx
  1002.     mov flags.debug,bl    ; Set the DEBUG flag.
  1003.     jmp RSkp
  1004. deb0:    pop bx
  1005.     ret
  1006. DEBST   ENDP
  1007.  
  1008. ; Turn bell on or off.    [17a start]
  1009.  
  1010. BELLST    PROC    NEAR
  1011.     mov dx,offset ontab
  1012.     mov bx,0
  1013.     mov ah,cmkey
  1014.     call comnd
  1015.      jmp r
  1016.     push bx
  1017.     mov ah,cmcfm
  1018.     call comnd
  1019.      jmp bel0
  1020.      nop
  1021.     pop bx
  1022.     mov flags.belflg,bl
  1023.     jmp RSkp
  1024. bel0:    pop bx
  1025.     ret
  1026. BELLST    ENDP                      ;  [17a end]
  1027.  
  1028. ; Toggle echo'ing of TAKE file to be either ON or OFF.
  1029. TAKSET    PROC    NEAR
  1030.     mov dx,offset ontab
  1031.     mov bx,0
  1032.     mov ah,cmkey
  1033.     call comnd
  1034.      jmp r
  1035.     push bx
  1036.     mov ah,cmcfm
  1037.     call comnd
  1038.      jmp tak0
  1039.      nop
  1040.     pop bx
  1041.     mov flags.takflg,bl
  1042.     jmp RSkp
  1043. tak0:    pop bx
  1044.     ret
  1045. TAKSET    ENDP                      ;  [17a end]
  1046.  
  1047. ; Set timer ON/OFF during file transfer.
  1048. TIMSET    PROC    NEAR
  1049.     mov dx,offset ontab
  1050.     mov bx,0
  1051.     mov ah,cmkey
  1052.     call comnd
  1053.      jmp r
  1054.     push bx
  1055.     mov ah,cmcfm
  1056.     call comnd
  1057.      jmp tim0
  1058.      nop
  1059.     pop bx
  1060.     mov flags.timflg,bl
  1061.     jmp RSkp
  1062. tim0:    pop bx
  1063.     ret
  1064. TIMSET    ENDP                      ;  [17a end]
  1065.  
  1066. ; Allow user to change the "Kermit-MS>" prompt.
  1067. PROMSET    PROC    NEAR
  1068.     mov ah,cmtxt
  1069.     mov bx,offset prm        ; Read in the prompt.
  1070.     mov dx,offset prmmsg
  1071.     call comnd
  1072.      jmp r
  1073.     cmp ah,0            ; Just a bare CR?
  1074.     jne prom0
  1075.     mov ax,offset kerm
  1076.     jmp prom1
  1077. prom0:    mov byte ptr [bx],'$'        ; End of string.
  1078.     mov ax,offset prm
  1079. prom1:    mov prmptr,ax            ; Remember it.
  1080.     jmp rskp
  1081. PROMSET    ENDP
  1082.  
  1083. ; Set Flow-Control subcommand.
  1084. FLOSET    PROC    NEAR
  1085.     mov dx,offset flotab
  1086.       xor bx,bx
  1087.     mov ah,cmkey
  1088.     call comnd
  1089.      jmp r
  1090.     push bx
  1091.     mov ah,cmcfm
  1092.     call comnd              ; Get a confirm.
  1093.      jmp flox        ; Didn't get a confirm.
  1094.      nop
  1095.     pop bx
  1096.     mov si,portval
  1097.     mov [si].flowc,bx    ; Flow control value.
  1098.     cmp bx,0        ; Turning it off?
  1099.     je flo0            ; Yes.
  1100.     mov [si].floflg,1    ; Say we're doing flow control.
  1101.     mov [si].hndflg,0    ; So don't do handshaking.
  1102.     jmp RSkp
  1103. flo0:    mov [si].floflg,bl    ; Say we're not doing flow control.
  1104.     jmp RSkp
  1105. flox:    pop bx
  1106.     ret
  1107. FLOSET    ENDP
  1108.  
  1109. ; Set Handshake subcommand.
  1110. HNDSET    PROC    NEAR
  1111.     mov dx,offset hndtab
  1112.     mov bx,0
  1113.     mov ah,cmkey
  1114.     call comnd
  1115.      jmp r
  1116.     push bx
  1117.     mov ah,cmcfm
  1118.     call comnd              ; Get a confirm.
  1119.      jmp hndx        ; Didn't get a confirm.
  1120.      nop
  1121.     pop bx
  1122.     mov si,portval
  1123.     cmp bl,0        ; Setting handshake off?
  1124.     je hnd0            ; Yes.
  1125.     mov [si].floflg,0    ; Else, turn flow control off.
  1126.     mov [si].hndflg,1    ; And turn on handshaking.
  1127.     mov [si].hands,bl    ; Use this char as the handshake.
  1128.     jmp RSkp
  1129. hnd0:    mov [si].hndflg,0    ; No handshaking.
  1130.     mov [si].floflg,1    ; If one is off, the other is on.
  1131.     jmp RSkp
  1132. hndx:    pop bx
  1133.     ret
  1134. HNDSET    ENDP
  1135.  
  1136. ; Set block check type sub-command.
  1137. BLKSET    PROC    NEAR
  1138.     mov dx,offset blktab
  1139.     mov bx,0
  1140.     mov ah,cmkey
  1141.     call comnd
  1142.      jmp r
  1143.     push bx
  1144.     mov ah,cmcfm
  1145.     call comnd              ; Get a confirm.
  1146.      jmp blk0        ; Didn't get a confirm.
  1147.      nop
  1148.     pop bx
  1149.     mov trans.chklen,bl    ; Use this char as the handshake.
  1150.     mov inichk,bl        ; Save here too.
  1151.     jmp RSkp
  1152. blk0:    pop bx
  1153.     ret
  1154. BLKSET    ENDP
  1155.  
  1156. ; Set destination for incoming file.
  1157. DESSET    PROC    NEAR
  1158.     mov dx,offset destab
  1159.     mov bx,0
  1160.     mov ah,cmkey
  1161.     call comnd
  1162.      jmp r
  1163.     push bx
  1164.     mov ah,cmcfm
  1165.     call comnd              ; Get a confirm.
  1166.      jmp des0        ; Didn't get a confirm.
  1167.        nop
  1168.     pop bx
  1169.     mov flags.destflg,bl    ; Set the destination flag.
  1170.     jmp RSkp
  1171. des0:    pop bx
  1172.     ret
  1173. DESSET    ENDP
  1174.  
  1175. ; Set default disk for sending/receiving, etc.
  1176. DSKSET    PROC    NEAR
  1177.     mov comand.cmcr,1    ; Don't want filename specified.
  1178.     mov ah,cmifi        ; Parse for drive specification.
  1179.     mov dx,offset rdbuf    ; Read into handy buffer.
  1180.     mov bx,offset dskhlp    ; Text of help message.
  1181.     call comnd
  1182.      jmp r
  1183.     mov ah,cmcfm
  1184.     call comnd
  1185.      jmp r
  1186.     cmp flags.nmoflg,0    ; Fail if specified file name.
  1187.     je dsk1
  1188. dsk0:    mov ah,prstr
  1189.     mov dx,offset dskerr    ; Illegal drive specification.
  1190.     int dos
  1191.     jmp RSkp
  1192. dsk1:    mov bx,offset rdbuf
  1193.     mov ah,[bx]        ; Get the drive they said to use.
  1194.     cmp ah,0        ; Did they type a bare CR?
  1195.     je dsk0            ; Yes, complain.
  1196.     mov curdsk,ah        ; And remember it.
  1197.  
  1198. ; Don't actually switch disks, just remember where sent/received files go
  1199.  
  1200. ;    dec ah
  1201. ;    mov dl,ah
  1202. ;    mov ah,seldsk
  1203. ;    int dos
  1204.  
  1205. ; Oh well, for now ...
  1206.  
  1207.     dec ah
  1208.     mov dl,ah
  1209.     mov ah,seldsk
  1210.     int dos
  1211.  
  1212.     jmp RSkp
  1213.  
  1214. DSKSET    ENDP    
  1215.  
  1216. ;  This function sets the baud rate.
  1217.  
  1218. BAUDST  PROC    NEAR
  1219.     mov dx,offset bdtab
  1220.     mov bx,0
  1221.     mov ah,cmkey
  1222.     call comnd
  1223.      jmp r
  1224.     push bx
  1225.     mov ah,cmcfm
  1226.     call comnd        ; Get a confirm.
  1227.      jmp bau0        ; Didn't get one.
  1228.       nop
  1229.     pop bx
  1230.     mov si,portval
  1231.     mov ax,[si].baud    ; Remember original value. [25]
  1232.     mov [si].baud,bx    ; Set the baud rate.
  1233.     call dobaud        ; Use common code. [19a] 
  1234.     jmp RSkp
  1235. bau0:    pop bx
  1236.     ret
  1237. BAUDST  ENDP
  1238.  
  1239. SENDSET    PROC    NEAR
  1240.     mov stflg,'S'        ; Setting SEND parameter 
  1241. sndst0: mov dx,offset stsrtb    ; Parse a keyword.
  1242.     mov bx,0
  1243.     mov ah,cmkey
  1244.     call comnd
  1245.      jmp r
  1246.     call bx
  1247.      nop
  1248.      nop
  1249.      nop
  1250.     jmp rskp
  1251. SENDSET    ENDP
  1252.  
  1253. recset:    mov stflg,'R'        ; Setting RECEIVE paramter.
  1254.     jmp sndst0
  1255.  
  1256. remset    proc    near
  1257.     mov    ah,cmkey
  1258.     mov    dx,offset ontab
  1259.     mov    bx,0
  1260.     call    comnd
  1261.      jmp    r
  1262.     push    bx        ; save parsed value
  1263.     mov    ah,cmcfm
  1264.     call    comnd        ; confirm
  1265.      pop    bx
  1266.      ret            ; return on failure
  1267.      nop
  1268.     pop    bx
  1269.     mov    flags.remflg,bl    ; set remote setting
  1270.     mov    flags.Real_RemFlg,bl ; Set "real" remote setting
  1271.     jmp    rskp        ; and return
  1272. remset    endp
  1273.  
  1274. ; Set send/receive start-of-header.
  1275. srsoh:    mov min,0
  1276.     mov max,1FH
  1277.     mov sum,0
  1278.     mov tmp,10
  1279.     mov desta,offset trans.ssoh    ; Assume SEND.
  1280.     cmp stflg,'S'            ; Setting SEND paramter?
  1281.     je srsoh0
  1282.     mov desta,offset trans.rsoh
  1283. srsoh0:    mov numhlp,offset eolhlp    ; Reuse help message.
  1284.     mov numerr,offset soherr
  1285.     mov temp1,0
  1286.     jmp num0        ; Common routine for parsing numerical input.
  1287.  
  1288. ; Set send/receive timeout.
  1289. srtim:    mov min,0
  1290.     mov max,94
  1291.     mov sum,0
  1292.     mov tmp,10
  1293.     mov desta,offset trans.stime    ; Assume SEND.
  1294.     cmp stflg,'S'            ; Setting SEND paramter?
  1295.     je srtim0
  1296.     mov desta,offset trans.rtime
  1297. srtim0:    mov numhlp,offset timhlp    ; Reuse help message.
  1298.     mov numerr,offset timerr
  1299.     mov temp1,0
  1300.     jmp num0        ; Common routine for parsing numerical input.
  1301.  
  1302. ; Set send/receive packet length.
  1303. srpack:    mov min,20
  1304.     mov max,94
  1305.     mov sum,0
  1306.     mov tmp,10
  1307.     mov desta,offset trans.spsiz
  1308.     cmp stflg,'S'        ; Setting SEND paramter?
  1309.     je srpak0
  1310.     mov desta,offset trans.rpsiz
  1311. srpak0:    mov numhlp,offset pakhlp
  1312.     mov numerr,offset pakerr
  1313.     mov temp1,0
  1314.     jmp num0        ; Parse numerical input.
  1315.  
  1316. ; Set send/receive number of padding characters.
  1317. srnpd:    mov min,0
  1318.     mov max,99
  1319.     mov sum,0
  1320.     mov tmp,10
  1321.     mov desta,offset trans.spad
  1322.     cmp stflg,'S'        ; Setting SEND paramter?
  1323.     je srnpd0
  1324.     mov desta,offset trans.rpad
  1325. srnpd0:    mov numhlp,offset npdhlp
  1326.     mov numerr,offset npderr
  1327.     mov temp1,0
  1328.     jmp num0        ; Parse numerical input.
  1329.  
  1330. ; Set send/receive padding character.
  1331. srpad:    mov min,0
  1332.     mov max,127
  1333.     mov sum,0
  1334.     mov tmp,10
  1335.     mov srtmp,0FFH        ; Haven't seen anything yet.
  1336.     mov desta,offset srtmp
  1337.     mov numhlp,offset padhlp
  1338.     mov numerr,offset paderr
  1339.     mov temp1,0
  1340.     mov savsp,sp
  1341.     call num0        ; Parse numerical input.
  1342.     mov sp,savsp
  1343.     mov temp,offset trans.spadch
  1344.     cmp stflg,'S'
  1345.     je srpad1
  1346.     mov temp,offset trans.rpadch
  1347. srpad1:    mov bx,offset srtmp
  1348.     mov ah,[bx]
  1349.     cmp ah,0FFH        ; Did they end up not doing the command?
  1350.     je srpad3
  1351.     cmp ah,127        ; This is allowed.
  1352.     je srpad2
  1353.     cmp ah,32
  1354.     jb srpad2        ; Between 0 and 31 is OK too.
  1355.     mov ah,prstr
  1356.     mov dx,offset paderr
  1357.     int dos
  1358.     jmp RSkp
  1359. srpad2:    mov bx,temp        ; Set the real pad char.
  1360.     mov [bx],ah
  1361. srpad3:    jmp RSkp
  1362.  
  1363. ; Set send/receive control character prefix.
  1364. srquo:    mov min,33
  1365.     mov max,126
  1366.     mov sum,0
  1367.     mov tmp,10
  1368.     mov desta,offset trans.rquote    ; Used for outgoing packets.
  1369.     cmp stflg,'S'            ; Setting outgoing quote char?
  1370.     je srquo0    
  1371.     mov desta,offset trans.squote    ; For incoming quote char.
  1372. srquo0:    mov numhlp,offset quohlp
  1373.     mov numerr,offset quoerr
  1374.     mov temp1,0
  1375.     jmp num0            ; Parse numerical input.
  1376.  
  1377.  
  1378. ; Set Card Monochrome, Color or EGA
  1379.  
  1380. Set_card PROC
  1381.  
  1382.     mov dx, OFFSET Card_tab
  1383.     mov bx,0
  1384.     mov ah,cmkey
  1385.     call comnd
  1386.      jmp r
  1387.     push bx
  1388.     mov ah,cmcfm
  1389.     call comnd              ; Get a confirm
  1390.      jmp SC_ret        ;  Didn't get a confirm
  1391.      nop
  1392.  
  1393.     mov Force_card, bl    ; Save the value we got
  1394.     pop bx
  1395.     jmp RSkp
  1396.  
  1397. SC_ret:    pop bx
  1398.     ret
  1399.  
  1400. Set_card ENDP
  1401.  
  1402.  
  1403. ; Set Display Color or Monochrome
  1404.  
  1405. Set_Display PROC
  1406.  
  1407.     mov dx, OFFSET Display_tab
  1408.     mov bx,0
  1409.     mov ah,cmkey
  1410.     call comnd
  1411.      jmp r
  1412.     push bx
  1413.     mov ah,cmcfm
  1414.     call comnd              ; Get a confirm
  1415.      jmp SD_ret        ;  Didn't get a confirm
  1416.      nop
  1417.  
  1418.     mov Force_mono, bl    ; Save the value we got
  1419.     pop bx
  1420.     jmp RSkp
  1421.  
  1422. SD_ret:    pop bx
  1423.     ret
  1424.  
  1425. Set_Display ENDP
  1426.  
  1427.  
  1428. ;       This is the STATUS command.
  1429.  
  1430. STATUS  PROC    NEAR
  1431.     mov ah,cmcfm
  1432.     call comnd              ; Get a confirm.
  1433.      jmp r                  ;  Didn't get a confirm.
  1434.     call stat0
  1435.     mov cx,di        ; End of buffer
  1436.     sub cx,ax        ; Get length of buffer.
  1437.     dec cx            ; Account for null.
  1438.     mov di,ax        ; Buffer pointer.
  1439.     call prtscr        ; Put data onto the screen. 
  1440.     jmp rskp
  1441. STATUS    ENDP
  1442.  
  1443. ; Return a pointer to status message in AX, ptr to end in DI.
  1444.  
  1445. STAT0   PROC    NEAR
  1446.     push    es
  1447.     mov    ax,ds
  1448.     mov    es,ax        ; address data segment
  1449.     cld            ; make sure strings go the right way
  1450.     mov    di,offset sttbuf ; point to destination buffer
  1451.     mov    bx,offset sttab    ; table to control printing
  1452.     mov    al,' '        ; start with a space
  1453.     stosb            ; in the buffer
  1454.     mov    ax,0        ; need-new-line flag
  1455. stat01:    cmp    word ptr [bx],0    ; end of table?
  1456.     je    stat02        ; yes, exit routine
  1457.     push    bx
  1458.     push    di        ; remember important values
  1459.     push    ax
  1460.     call    [bx].sttyp    ; call the appropriate routine
  1461.     pop    ax
  1462.     pop    cx        ; return buffer value
  1463.     pop    bx        ; and ptr
  1464.     or    ax,ax        ; do we need a newline?
  1465.     jne    stat03        ; yes, go put one in
  1466.     sub    cx,di        ; else see how many columns they used
  1467.     add    cx,40        ; this is where we'd like to be
  1468. ; if cx is negative here, we have a problem...
  1469.     mov    al,' '
  1470.     rep    stosb        ; add right # of spaces
  1471.     mov    ax,1        ; note we need a newline next time
  1472.     jmp    short stat04    ; and keep looping around
  1473. stat03:    mov    cx,3
  1474.     mov    si,offset crlfsp
  1475.     rep    movsb        ; append crlf to string
  1476.     xor    ax,ax        ; reset newline flag
  1477. stat04:    add    bx,size stent    ; advance to next one
  1478.     jmp    stat01
  1479. stat02:    mov al, Cr        ; End with an extra CrLf
  1480.     stosb
  1481.     mov al, Lf
  1482.     stosb
  1483.     mov    al,0        ; end buffer
  1484.     stosb
  1485.     mov    ax,offset sttbuf
  1486.     pop    es        ; restore this
  1487.     ret            ; and return
  1488. STAT0    ENDP
  1489.  
  1490. ; handler routines for status
  1491. ; all are called with di/ destination buffer, bx/ stat ptr.  They
  1492. ; can change any register but the segment registers, must update
  1493. ; di to the end of the buffer.
  1494.  
  1495. ; copy the message into the buffer
  1496. stmsg    proc    near
  1497.     mov    si,[bx].msg    ; get message address
  1498. stms1:    lodsb            ; get a byte
  1499.     stosb            ; drop it off
  1500.     cmp    al,'$'        ; end of message?
  1501.     jne    stms1        ; no, keep going
  1502.     dec    di        ; else back up ptr
  1503.     ret            ; and return
  1504. stmsg    endp
  1505.  
  1506. ; get address of test value in stent.  Returns address in si
  1507. stval    proc    near
  1508.     mov    si,[bx].basval    ; get base value
  1509.     cmp    si,0        ; any there?
  1510.     je    stva1        ; no, keep going
  1511.     mov    si,[si]        ; yes, use as base address
  1512. stva1:    add    si,[bx].tstcel    ; add offset of test cell
  1513.     ret            ; and return it
  1514. stval    endp
  1515.  
  1516. ; print a single character
  1517. onechr    proc    near
  1518.     call    stmsg        ; copy message part first
  1519.     call    stval        ; pick up test value address
  1520.     mov    al,[si]        ; this is char to print
  1521.     cmp    al,' '        ; printable?
  1522.     jae    onech1        ; yes, keep going
  1523.     add    al,64        ; make printable.
  1524.     mov    byte ptr [di],'^'
  1525.     inc    di        ; note ctrl char
  1526. onech1:    stosb            ; drop char off
  1527.     ret            ; and return
  1528. onechr    endp
  1529.  
  1530. ; numeric field...
  1531. stnum    proc    near
  1532.     call    stmsg        ; copy message
  1533.     call    stval        ; pick up value address
  1534.     mov    al,[si]        ; get value
  1535.     mov    ah,0        ; high order is 0
  1536.     call    outnum        ; put number into buffer
  1537.     ret            ; and return
  1538. stnum    endp
  1539.  
  1540. ; translate the number in ax...
  1541. outnum    proc    near
  1542.     cwd
  1543.     mov    bx,10
  1544.     div    bx        ; divide to get digit
  1545.     push    dx        ; save remainder digit
  1546.     or    ax,ax        ; test quotient
  1547.     jz    outnu1        ; zero, no more of number
  1548.     call    outnum        ; else call for rest of number
  1549. outnu1:    pop    ax        ; get digit back
  1550.     add    al,'0'        ; make printable
  1551.     stosb            ; drop it off
  1552.     ret            ; and return
  1553. outnum    endp
  1554.  
  1555. ; on/off field
  1556. onoff    proc    near
  1557.     call    stmsg        ; copy message
  1558.     call    stval        ; get value cell
  1559.     mov    al,[si]
  1560.     mov    si,offset onmsg
  1561.     mov    cx,2        ; assume 2-byte 'ON' message
  1562.     or    al,al        ; test value
  1563.     jnz    onof1        ; on, have right msg
  1564.     mov    si,offset offmsg
  1565.     mov    cx,3
  1566. onof1:    rep    movsb        ; copy right message in
  1567.     ret            ; and return
  1568. onoff    endp
  1569.  
  1570. ; Display permitted to be Color or forced to be Monochrome
  1571.  
  1572. Display    PROC
  1573.  
  1574.     call    stmsg        ; copy message
  1575.     call    stval        ; get value cell
  1576.     mov    al,[si]
  1577.     mov    si,offset Display_color
  1578.     mov    cx, 21        ; assume Color message
  1579.     or    al,al        ; test value
  1580.      jz    Disp_1        ;  It's COLOR
  1581.  
  1582.     mov    si,offset Display_mono
  1583.     mov    cx, 23        ; Monochrome message
  1584.  
  1585. Disp_1:    rep    movsb        ; Copy right message in
  1586.     ret            ;  and return
  1587.  
  1588. Display    ENDP
  1589.  
  1590.  
  1591. ; print first message if false, second if true
  1592. msg2    proc    near
  1593.     call    stval        ; get value cell
  1594.     mov    al,[si]
  1595.     mov    si,[bx].msg    ; assume off
  1596.     or    al,al        ; is it?
  1597.     jz    msg21        ; yes, continue
  1598.     mov    si,[bx].val2    ; else use alternate message
  1599. msg21:    jmp    stms1        ; handle copy and return
  1600. msg2    endp
  1601.  
  1602. ; search a keyword table for a value, print that value
  1603. srchkw    proc    near
  1604.     call    stmsg        ; first print message
  1605.     call    stval
  1606.     mov    al,[si]        ; get value to hunt for
  1607.     mov    ah,0        ; high order is 0
  1608.     mov    bx,[bx].val2    ; this is table address
  1609.     jmp    prttab        ; and look in table.
  1610. srchkw    endp
  1611.  
  1612. ; Print the drive name.
  1613. drnum    proc    near
  1614.     call    stmsg        ; copy message part first
  1615.     call    stval        ; pick up test value address
  1616.     mov    al,[si]        ; this is char to print
  1617.     add    al,'@'        ; Make it printable.
  1618.     stosb
  1619.     mov    byte ptr [di],':'
  1620.     inc    di        ; end with a colon
  1621.     ret            ; and return
  1622. drnum    endp
  1623.  
  1624. ; print 8-bit quoting
  1625. pr8bit    proc    near
  1626.     mov    bl,trans.ebquot    ; get quote char
  1627.     mov    si,offset ebyst    ; assume no 8-bit quoting
  1628.     cmp    bl,'Y'        ; on request only?
  1629.     je    pr8bi1        ; yes, continue
  1630.     mov    si,offset ebvst    ; else variable
  1631. pr8bi1:    call    stms1        ; copy message in
  1632.     cmp    bl,'Y'        ; not doing it?
  1633.     je    pr8bi2        ; no, forget this part
  1634.     mov    [di],bl        ; else drop off char too
  1635.     inc    di
  1636. pr8bi2:    ret            ; and return
  1637. pr8bit    endp
  1638.  
  1639. ; Print the handshake.
  1640. prhnd:    mov si,offset handst    ; copy in initial message
  1641.     call stms1
  1642.     mov si,offset nonmsg    ; assume no handshake
  1643.     mov bx,portval
  1644.     cmp [bx].hndflg,0    ; Is handshaking in effect?
  1645.     jne prh0        ; Yes, print what we're using.
  1646.     jmp stms1        ; no, say so and return
  1647. prh0:    mov al,'^'        ; Doing handshaking with control char.
  1648.     stosb
  1649.     mov al,[bx].hands
  1650.     add al,40H        ; Make printable.
  1651.     stosb            ; put in buffer
  1652.     ret            ; and return
  1653.  
  1654. ; Print the pad character in AL.
  1655. prpad:    cmp al,127        ; Are they using a delete?
  1656.     jne prpad0
  1657.     mov ah,prstr
  1658.     mov dx,offset delmsg
  1659.     int dos
  1660.     ret
  1661. prpad0:    mov dl,'^'
  1662.     mov ah,conout
  1663.     push ax
  1664.     int dos
  1665.     pop ax
  1666.     mov dl,al
  1667.     add dl,40H        ; Make printable.
  1668.     int dos
  1669.     ret
  1670.  
  1671. ; Print value from table.  BX/address of table, AL/value of variable.
  1672. prttab:    mov cl,[bx]        ; Number of entries in our table.
  1673.     inc bx            ; Point to the data.
  1674. prtt0:    mov dl,[bx]        ; Length of keyword.
  1675.     inc bx            ; Point to keyword.
  1676.     mov dh,0
  1677.     inc dx            ; Account for "$" in table.
  1678.     mov si,dx        ; Put to index register.
  1679.     cmp ax,[bx+si]        ; Is this the one?
  1680.     je prtt1
  1681.     add bx,dx        ; Go to end of keyword.
  1682.     add bx,2        ; Point to next keyword.
  1683.     dec cl            ; Any more keywords to check?
  1684.     jnz prtt0        ; Yes, go to it.
  1685.     mov bx,offset prterr
  1686. prtt1:    mov si,bx
  1687. prtt2:    jmp stms1        ; copy in message
  1688.     ret            ; and return
  1689.  
  1690. ;    This routine prints out the escape character in readable format.  
  1691.  
  1692. ESCPRT    PROC    NEAR        ; [6 start]
  1693.     mov dl,trans.escchr
  1694.     cmp dl,' '
  1695.     jge escpr2
  1696.     push dx
  1697.     mov ah,prstr
  1698.     mov dx,offset esctl
  1699.     int dos
  1700.     pop dx
  1701.     add dl,040H        ; Make it printable.
  1702. escpr2:    mov ah,conout
  1703.     int dos
  1704.     ret
  1705. ESCPRT    ENDP            ; [6 end]
  1706.  
  1707. ; Print information on the baud rate. [19a]
  1708.  
  1709. BAUDPRT    PROC     NEAR
  1710.     mov si,portval
  1711.     mov ax,[si].baud
  1712.     mov dx,offset b48st    ; Assume 4800 baud.
  1713.     cmp ax,B4800
  1714.     jnz bdprt0
  1715.     jmp bdprt2
  1716. bdprt0:    mov dx,offset b12st
  1717.     cmp ax,B1200
  1718.     jnz bdprt1
  1719.     jmp bdprt2
  1720. bdprt1:    mov dx,offset b18st
  1721.     cmp ax,B1800
  1722.     jz bdprt2
  1723.     mov dx,offset b24st
  1724.     cmp ax,B2400
  1725.     jz bdprt2
  1726.     mov dx,offset b96st
  1727.     cmp ax,B9600
  1728.     jz bdprt2
  1729.     mov dx,offset b03st
  1730.     cmp ax,B0300
  1731.     jz bdprt2
  1732.     mov dx,offset b04st
  1733.     cmp ax,B00455
  1734.     jz bdprt2
  1735.     mov dx,offset b05st
  1736.     cmp ax,B0050
  1737.     jz bdprt2
  1738.     mov dx,offset b07st
  1739.     cmp ax,b0075
  1740.     jz bdprt2
  1741.     mov dx,offset b11st
  1742.     cmp ax,B0110
  1743.     jz bdprt2
  1744.     mov dx,offset b13st
  1745.     cmp ax,B01345
  1746.     jz bdprt2
  1747.     mov dx,offset b15st
  1748.     cmp ax,B0150
  1749.     jz bdprt2
  1750.     mov dx,offset b06st
  1751.     cmp ax,B0600
  1752.     je bdprt2
  1753.     mov dx,offset b20st
  1754.     cmp ax,B2000
  1755.     jz bdprt2
  1756.     mov dx,offset b19st
  1757.     cmp ax,B19200
  1758.     jz bdprt2
  1759.     mov dx,offset b23st
  1760.     cmp ax,b23040
  1761.     jz bdprt2
  1762.     mov dx,offset b38st
  1763.     cmp ax,b38400
  1764.     jz bdprt2
  1765.     mov dx,offset unrec    ; Unrecognized baud rate.
  1766. bdprt2:    mov si,dx        ; this is baud rate
  1767. bdprt3:    jmp stms1        ; go copy it and return
  1768. BAUDPRT    ENDP
  1769.  
  1770. setkey    proc    near        
  1771.     call Get_Set_Key_table_size ; Get the size of the table in al
  1772.     or al, al        ; Any table?
  1773.     jne    setk0        ; yes, use it
  1774.     mov    dx,offset ermes5
  1775.     jmp    reterr        ; else print error message
  1776.  
  1777. setk0:    call Parse_for_Set_Key    ; Handle machine-specifically
  1778.      jmp r            ;  Failed
  1779.  
  1780.     cmp    bx,-1        ;[jd] do we have scan code?
  1781.     jne    setk1        ;[jd] yes, skip this part
  1782.  
  1783.     mov    ah,cmtxt
  1784.     mov    bx,offset rdbuf    ; handy buffer
  1785.     mov     dx,offset sk1msg
  1786.     call    comnd
  1787.      jmp    r        ; fail return
  1788.     mov    si,offset rdbuf    ; this is parsed number
  1789.     call    atoi        ; Convert input to real number.
  1790.      jmp    reterr        ; No good.
  1791.     mov    bx,ax        ; put accumulation into bl
  1792. setat3:    cmp    bx,0        ; is scan code 0?
  1793.     jne    setk2        ; no, have scan code, look for def
  1794.  
  1795. setk1:    push    bx        ; save our scan code
  1796.     mov    ah,cmcfm
  1797.     call    comnd
  1798.      jmp     short setkx    ; no good, pop bx and return
  1799.     nop            ; waste a byte
  1800.     pop    bx
  1801. ; scan code is in bl, ask for string part
  1802. setk2:    push    bx
  1803.     mov    dx,offset defpmp
  1804.     call    prompt
  1805.     mov    ah,cmtxt
  1806.     mov    bx,offset rdbuf
  1807.     mov    dx,offset sk2msg
  1808.     call    comnd        ; read the definition
  1809.      jmp    short setkx    ; pop bx and fail return
  1810.      nop
  1811.     mov    cl,ah
  1812.     mov    ch,0        ; set up length of definition
  1813.     pop    ax        ; get scan code back
  1814.     mov    si,offset rdbuf    ; point to definition
  1815.     call    defkey        ; go define the key
  1816.     jmp    rskp        ; and return
  1817. setkx:    pop    bx        ; pop junk off stack
  1818.     ret            ; and return
  1819. setkey    endp
  1820.  
  1821. ; Convert input in buffer pointed to by SI to real number which is returned
  1822. ; in AX.  Return on failure, return skip on success.
  1823. ATOI    PROC    NEAR
  1824.     mov    cl,ah        ; Number of chars of input.
  1825.     mov    ch,0        ; size of string
  1826.     jcxz    atoi4        ; Fail on no input.
  1827.     mov    ax,0        ; init sum
  1828.     mov    bh,0        ; high order of this stays 0.
  1829. atoi0:    xchg    al,bl        ; save current sum
  1830.     lodsb            ; grab a byte
  1831.     cmp    al,' '        ; leading space?
  1832.     jne    atoi1        ; no, continue
  1833.     xchg    al,bl        ; put sum back
  1834.     jmp    short atoi2    ; and continue loop
  1835. atoi1:    cmp    al,'9'
  1836.     ja    atoi3        ; out of range, done
  1837.     cmp    al,'0'
  1838.     jb    atoi3
  1839.     xchg    al,bl        ; put sum back into al
  1840.     mul    ten        ; shift one digit
  1841.     sub    bl,'0'        ; convert to binary
  1842.     add    ax,bx        ; add to sum
  1843. atoi2:    loop    atoi0        ; loop thru all chars
  1844. atoi3:    jmp    rskp
  1845. atoi4:    mov    dx,offset erms23    ; complain and return
  1846.     ret
  1847. ATOI    ENDP
  1848.  
  1849. ;  addition for capture of raw output
  1850.  
  1851. setcpt    proc    near
  1852.     test    flags.capflg,0FFH
  1853.     jz    setcp1            ; no capture file, keep going
  1854.     mov    dx,offset erms24
  1855.     jmp    reterr
  1856. setcp1:    mov     comand.cmcr,0        ; Filename must be specified.
  1857.     mov    ah,cmifi
  1858.     mov    dx,offset cptfcb
  1859.     mov     bx,offset filhlp
  1860.     call    comnd
  1861.      jmp    r
  1862.     mov    ah,cmcfm
  1863.     call    comnd            ; confirm with carriage return
  1864.      jmp    r
  1865.     mov    ah,delf
  1866.     mov    dx,offset cptfcb
  1867.     int    dos            ; open up file
  1868.     mov    ah,makef
  1869.     mov    dx,offset cptfcb
  1870.     int    dos
  1871.     mov     cptfcb+32,0
  1872.  
  1873.     call    inicpt            ; init capture variables
  1874.     mov    flags.capflg,0FFH    ; know we have capture routine
  1875.     jmp    rskp        ; and return
  1876.  
  1877. setcpt    endp
  1878.  
  1879. ; Jumping to this location is like retskp.  It assumes the instruction
  1880. ;   after the call is a jmp addr.
  1881.  
  1882. RSKP    PROC    NEAR
  1883.     pop bp
  1884.     add bp,3
  1885.     push bp
  1886.     ret
  1887. RSKP    ENDP
  1888.  
  1889. ; Jumping here is the same as a ret.
  1890.  
  1891. R       PROC    NEAR
  1892.     ret
  1893. R       ENDP
  1894.  
  1895. ; routine to print an error message, then retskp
  1896. ; expects message in dx
  1897. reterr    proc    near
  1898.     mov    ah,prstr
  1899.     int    dos
  1900.     jmp    rskp
  1901. reterr    endp
  1902.  
  1903. code    ends 
  1904.     end
  1905. 
  1906.